<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="tutorial.css">
<TITLE>
Exercises
</TITLE>
</HEAD>
<BODY >
<A HREF="tutorial105.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="tutorial098.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc210">14.8</A>&nbsp;&nbsp;Exercises</H2>

<OL CLASS="enumerate" type=1><LI CLASS="li-enumerate">Implement a constraint atmost/3 
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
atmost(+N, +List, +V)
</PRE></BLOCKQUOTE>
 which takes an integer N, an integer V and a list List
 containing integers or integer domain variables.<BR>
<BR>
Meaning: at most N elements of List have value V.<BR>
<BR>
Behaviour: Fail as soon as too many list elements are
 instantiated to value V.
 This requires only basic suspension facilities, no domain
 information needs to be taken into account.<BR>
<BR>
Tests are provided in the file <TT>atmost.tst</TT>.
 You can test your constraint by loading the library <TT>lib(test_util)</TT>
 and then calling <TT>test(atmost)</TT>.<BR>
<BR>
<LI CLASS="li-enumerate">Implement a constraint offset/3
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
offset(?X,+Const,?Y)
</PRE></BLOCKQUOTE>
which is declaratively like
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
offset(X,Const,Y) :- Y #= X+Const.
</PRE></BLOCKQUOTE>
 but maintains domain-arc-consistency (i.e. propagates
 "holes", while the above definition only maintains
 bounds-consistency).<BR>
<BR>
Use suspension built-ins and domain-access primitives
 from the ic_kernel module.
 Use not_unify/2 to test whether a value is outside
 a variable's domain.<BR>
<BR>
Tests are provided in the file <TT>offset.tst</TT>.
 You can test your constraint by loading the library <TT>lib(test_util)</TT>.
 and then calling <TT>test(offset)</TT>.</OL>
<HR>
<A HREF="tutorial105.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="tutorial098.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
</BODY>
</HTML>
